inherit CometExpeEmeric Logical_consistency

#___________________________________________________________________________________________________________________________________________
proc Root_of_CometExpeEmeric {} "return {[string map [list " " {\ }] [pwd]]/}"
if {![file exists [Root_of_CometExpeEmeric]]} {
  proc Root_of_CometExpeEmeric {} "return {[pwd]/}"
 }
#___________________________________________________________________________________________________________________________________________
method CometExpeEmeric constructor {name descr args} {
 this inherited $name $descr
 this set_GDD_id CT_CometExpeEmeric

 # Inner graph
 set this(cont_all)    [CPool get_a_comet CometContainer -Add_style_class "CONTAINER ALL"]
 set this(cont_tirage) [CPool get_a_comet CometContainer -Add_style_class "CONTAINER TIRAGE"]
 set this(cont_element_1) [CPool get_a_comet CometContainer -Add_style_class "CONTAINER ELEMENT 1"]
 set this(cont_element_2) [CPool get_a_comet CometContainer -Add_style_class "CONTAINER ELEMENT 1"]
 set this(cont_element_3) [CPool get_a_comet CometContainer -Add_style_class "CONTAINER ELEMENT 1"]
 
 $this(cont_tirage) Add_daughters_R [list $this(cont_element_1) $this(cont_element_2) $this(cont_element_3)]
 
 # Facets
 set CFC ${objName}_CFC; CometExpeEmeric_CFC $CFC; this set_Common_FC $CFC

 set this(LM_FC) ${objName}_LM_FC
 CometExpeEmeric_LM_FC $this(LM_FC) $this(LM_FC) "The LM LM_FC of $name"
   this Add_LM $this(LM_FC)
 set this(LM_LP) ${objName}_LM_LP
 CometExpeEmeric_LM_LP $this(LM_LP) $this(LM_LP) "The LM LM_LP of $name"
   this Add_LM $this(LM_LP)
   
 # Configuration  
 eval "$objName configure $args"
 return $objName
}

#___________________________________________________________________________________________________________________________________________
method CometExpeEmeric dispose {} {this inherited}
#___________________________________________________________________________________________________________________________________________
#___________________________________________________________________________________________________________________________________________
#___________________________________________________________________________________________________________________________________________
Methodes_set_LC CometExpeEmeric [P_L_methodes_set_CometExpeEmeric] {$this(FC)} {$this(L_LM)}
Methodes_get_LC CometExpeEmeric [P_L_methodes_get_CometExpeEmeric] {$this(FC)}

#___________________________________________________________________________________________________________________________________________
Generate_accessors CometExpeEmeric [list cont_all cont_tirage cont_element_1 cont_element_2 cont_element_3]

#___________________________________________________________________________________________________________________________________________
#___________________________________________________________________________________________________________________________________________
#___________________________________________________________________________________________________________________________________________
Inject_code CometExpeEmeric ReInit {} {
                                       this set_L_base_pour_tirage [this get_L_base_pour_tirage]
									  }

#___________________________________________________________________________________________________________________________________________
Inject_code CometExpeEmeric set_L_base_pour_tirage {
  foreach img [$this(cont_all) get_out_daughters] {CPool Release_a_comet $img}
  foreach e $v {
    set C [CPool get_a_comet CometImage]
	  if {[catch {$C load_img $e} err]} {puts "Error while loading \"$e\""}
	  $C Add_style_class [list $e]
	  $this(cont_all) Add_daughter_R $C
   }
 } {}
 
#___________________________________________________________________________________________________________________________________________
Inject_code CometExpeEmeric Add_L_base_pour_tirage {
  set C [CPool get_a_comet CometImage]
    $C load_img $v 
	$C Add_style_class [list $v]
    $this(cont_all) Add_daughter_R $C
 } {}

#___________________________________________________________________________________________________________________________________________
Inject_code CometExpeEmeric Sub_L_base_pour_tirage {
  foreach C [CSS++ $objName "#$this(cont_all) > CometImage\[img_file_name == [list $v]\]"] {
    CPool Release_a_comet $C
   }
 } {}

 
#___________________________________________________________________________________________________________________________________________
Inject_code CometExpeEmeric set_tirage_courant  {
  set L_img [list]
  foreach img_name $v {
    lappend L_img [CSS++ $objName "#$this(cont_all) > CometImage\[img_file_name == [list $img_name]\]"]
   }
  for {set i 1} {$i <= 3} {incr i} {$this(cont_element_$i) set_daughters_R [lindex $L_img [expr $i - 1]]}
 } {}

#___________________________________________________________________________________________________________________________________________
Manage_CallbackList CometExpeEmeric [list set_tirage_courant Valider_et_passer_au_suivant Interdir_et_passer_au_suivant] end

#___________________________________________________________________________________________________________________________________________
 set cmd {
 if {![this get_retirage_si_pas_trouve_double]} {
   this Valider_et_passer_au_suivant
  } else }
 append cmd "\{"
 
 Inject_code CometExpeEmeric Interdir_et_passer_au_suivant $cmd "\}"

